<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="出库类型" prop="chukuType">
        <el-select v-model="queryParams.chukuType" placeholder="请选择出库类型" clearable>
          <el-option
            v-for="dict in dict.type.asset_chuku_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="资产名称" prop="assetName">
        <el-input
          v-model="queryParams.assetName"
          placeholder="请输入资产名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="条码号" prop="barcode">
        <el-input
          v-model="queryParams.barcode"
          placeholder="请输入条码号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="spec">
        <el-input
          v-model="queryParams.spec"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商名称" prop="supplierName">
        <el-select clearable style="width: 100%" filterable v-model="queryParams.supplierName" placeholder="供应商" >
          <el-option
            v-for="dict in supplyOptions"
            :key="dict.supplierCode"
            :label="dict.supplierName"
            :value="dict.supplierName"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="审核状态" prop="shStatus">
        <el-select v-model="queryParams.shStatus" placeholder="请选择审核状态" clearable>
          <el-option
            v-for="dict in dict.type.zcrk_sh_state"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['sales:AssetChuku:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['sales:AssetChuku:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['sales:AssetChuku:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['sales:AssetChuku:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="info"
            plain
            icon="el-icon-upload2"
            size="mini"
            @click="handleImport"
        >导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-s-opportunity"
          size="mini"
          :disabled="multiple"
          @click="handleSh"
        >审核</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-s-opportunity"
          size="mini"
          :disabled="multiple"
          @click="handleQx"
        >取消审核</el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="warning"-->
<!--          plain-->
<!--          icon="el-icon-s-opportunity"-->
<!--          size="mini"-->
<!--          :disabled="multiple"-->
<!--          @click="handleCj"-->
<!--        >创建资产</el-button>-->
<!--      </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="AssetChukuList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
<!--      <el-table-column label="主键ID" align="center" prop="id" />-->
<!--      <el-table-column label="组织代码" align="center" prop="orgCode" />-->
<!--      <el-table-column label="组织名称" align="center" prop="orgName" />-->
      <el-table-column label="出库类型" align="center" prop="chukuType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.asset_chuku_type" :value="scope.row.chukuType"/>
        </template>
      </el-table-column>
      <el-table-column width="150" label="出库单号" align="center" prop="danhao" />
      <el-table-column width="120" label="科室" align="center" prop="deptName" />
<!--      <el-table-column label="资产代码" align="center" prop="assetNumber" />-->
      <el-table-column label="分类名称" align="center" prop="assetType" />
      <el-table-column label="子类名称" align="center" prop="assetClass" />
      <el-table-column label="资产编码" align="center" prop="assetCode" />
      <el-table-column label="资产名称" align="center" prop="assetName" />
      <el-table-column width="120" label="条码号" align="center" prop="barcode" />
<!--      <el-table-column width="120" label="物料识别码" align="center" prop="materialCode" />-->
      <el-table-column label="品牌" align="center" prop="brand" />
      <el-table-column label="规格型号" align="center" prop="spec" />
      <el-table-column label="购置时间" align="center" prop="buyTime" width="180"/>
      <el-table-column label="使用寿命" align="center" prop="useLife" />
      <el-table-column label="单位" align="center" prop="unit" />
      <el-table-column width="120" label="供应商编码" align="center" prop="supplierCode" />
      <el-table-column width="120" label="供应商名称" align="center" prop="supplierName" />
<!--      <el-table-column label="制造商编码" align="center" prop="manufactureCode" />-->
<!--      <el-table-column label="制造商名称" align="center" prop="manufactureName" />-->
<!--      <el-table-column label="资产图片" align="center" prop="assetImg" width="100">-->
<!--        <template slot-scope="scope">-->
<!--          <image-preview :src="scope.row.assetImg" :width="50" :height="50"/>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="资产保养周期" align="center" prop="assetMaintenance" />-->
<!--      <el-table-column label="资产维护周期" align="center" prop="assetPhold" />-->
<!--      <el-table-column label="资产程序代码" align="center" prop="assetProgramCode" />-->
<!--      <el-table-column label="资产程序包" align="center" prop="assetProgramPackage" />-->
<!--      <el-table-column label="计划数量" align="center" prop="plannNum" />-->
      <el-table-column label="出库数量" align="center" prop="chukuNum" />
      <el-table-column label="单价" align="center" prop="unitPrice" />
      <el-table-column label="金额" align="center" prop="amount">
        <template slot-scope="scope">
          <div>{{ (scope.row.chukuNum-0)*(scope.row.unitPrice-0) }}</div>
        </template>
      </el-table-column>
      <el-table-column label="库位" align="center" prop="kuweiCode"/>
      <el-table-column label="审核状态" align="center" prop="shStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.zcrk_sh_state" :value="scope.row.shStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="审核人" align="center" prop="shName" />
      <el-table-column width="120" label="审核时间" align="center" prop="shDate" />
<!--      <el-table-column label="使用年限" align="center" prop="usefulLife" />-->
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['sales:AssetChuku:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['sales:AssetChuku:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加资产出库对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1400px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="出库类型" prop="chukuType">
              <el-select v-model="form.chukuType" placeholder="请选择出库类型">
                <el-option
                  v-for="dict in dict.type.asset_chuku_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="科室" prop="deptId">
              <treeselect @select="handleSelect"  v-model="form.deptId" :clearable="true" :options="deptOptions" :show-count="true" placeholder="请选择科室" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-button type="primary" @click="checkZc">选择库存</el-button>
      <el-divider>资产出库明细</el-divider>
      <el-table v-loading="loading" :data="checkList" >
        <el-table-column type="selection" width="55" align="center" />
<!--        <el-table-column label="主键ID" align="center" prop="id" />-->
<!--        <el-table-column label="组织代码" align="center" prop="orgCode" />-->
<!--        <el-table-column label="组织名称" align="center" prop="orgName" />-->
<!--        <el-table-column label="出库类型" align="center" prop="chukuType">-->
<!--          <template slot-scope="scope">-->
<!--            <dict-tag :options="dict.type.asset_chuku_type" :value="scope.row.chukuType"/>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column label="资产代码" align="center" prop="assetNumber" />-->
        <el-table-column label="资产编码" align="center" prop="assetCode" />
        <el-table-column label="资产类型" align="center" prop="assetType" />
        <el-table-column label="资产大类" align="center" prop="assetClass" />
        <el-table-column label="资产名称" align="center" prop="assetName" />
        <el-table-column label="条码号" align="center" prop="barcode" />
<!--        <el-table-column width="120" label="物料识别码" align="center" prop="materialCode" />-->
        <el-table-column label="品牌" align="center" prop="brand" />
        <el-table-column label="规格型号" align="center" prop="spec" />
        <el-table-column label="购置时间" align="center" prop="buyTime" width="180"/>
        <el-table-column label="使用寿命" align="center" prop="useLife" />
        <el-table-column width="150" label="供应商编码" align="center" prop="supplierCode" />
        <el-table-column width="150" label="供应商名称" align="center" prop="supplierName" />
<!--        <el-table-column label="制造商编码" align="center" prop="manufactureCode" />-->
<!--        <el-table-column label="制造商名称" align="center" prop="manufactureName" />-->
<!--        <el-table-column label="资产图片" align="center" prop="assetImg" width="100">-->
<!--          <template slot-scope="scope">-->
<!--            <image-preview :src="scope.row.assetImg" :width="50" :height="50"/>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column label="资产保养周期" align="center" prop="assetMaintenance" />-->
<!--        <el-table-column label="资产维护周期" align="center" prop="assetPhold" />-->
<!--        <el-table-column label="资产程序代码" align="center" prop="assetProgramCode" />-->
<!--        <el-table-column label="资产程序包" align="center" prop="assetProgramPackage" />-->
<!--        <el-table-column label="计划数量" align="center" prop="plannNum" />-->
        <el-table-column label="可用数量" align="center" prop="kcNum" />
        <el-table-column width="180" label="出库数量" align="center" prop="chukuNum">
          <template slot-scope="scope">
            <el-input-number size="small" v-model="scope.row.chukuNum" placeholder="出库数量" />
          </template>
        </el-table-column>
        <el-table-column label="单价" align="center" prop="unitPrice" />
<!--        <el-table-column label="金额" align="center" prop="amount" />-->
        <el-table-column label="库位" align="center" prop="kuweiCode">
          <template>
            <template slot-scope="scope">
              <el-cascader
                v-model="scope.row.warehouse"
                placeholder="请选择仓库/库区/库位"
                :show-all-levels="false"
                clearable
                @change="handleChange(scope.row)"
                filterable
                :show-count="true"
                :options="warehouseinfo">
              </el-cascader>
            </template>
          </template>
        </el-table-column>

<!--        <el-table-column label="使用年限" align="center" prop="usefulLife" />-->
        <el-table-column label="备注" align="center" prop="remark" />
<!--        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!--          <template slot-scope="scope">-->
<!--            <el-button-->
<!--              size="mini"-->
<!--              type="text"-->
<!--              icon="el-icon-edit"-->
<!--              @click="handleUpdate(scope.row)"-->
<!--              v-hasPermi="['sales:AssetChuku:edit']"-->
<!--            >修改</el-button>-->
<!--            <el-button-->
<!--              size="mini"-->
<!--              type="text"-->
<!--              icon="el-icon-delete"-->
<!--              @click="handleDelete(scope.row)"-->
<!--              v-hasPermi="['sales:AssetChuku:remove']"-->
<!--            >删除</el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 修改资产出库对话框 -->
    <el-dialog :title="title" :visible.sync="openChange" width="1400px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="出库类型" prop="chukuType">
              <el-select v-model="form.chukuType" placeholder="请选择出库类型">
                <el-option
                  v-for="dict in dict.type.asset_chuku_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="科室" prop="deptId">
              <treeselect @select="handleSelect"  v-model="form.deptId" :clearable="true" :options="deptOptions" :show-count="true" placeholder="请选择科室" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="资产编码" prop="assetCode">
              <el-input disabled v-model="form.assetCode" placeholder="资产编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="资产名称" prop="assetName">
              <el-input disabled v-model="form.assetName" placeholder="资产名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="出库数量" prop="chukuNum">
              <el-input-number size="small" v-model="form.chukuNum" placeholder="出库数量" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormChange">确 定</el-button>
        <el-button @click="cancelChange">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url + '?updateSupport=' + upload.updateSupport"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="资产库存明细" :visible.sync="zcOpen" width="1400px" append-to-body>
      <el-row>
        <el-col :span="24">
          <ChukuAdd :getForm="form" ref="chukuAdd"></ChukuAdd>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitZc">确 定</el-button>
        <el-button @click="zcOpen = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listAssetChuku, getAssetChuku, delAssetChuku, addAssetChuku, updateAssetChuku,cksh,ckshqx,cjzc } from "@/api/sales/AssetChuku";
import {getToken} from "@/utils/auth";
import ChukuAdd from "./chukuAdd";
import {getWarehouseTree,getListWarehouseinfoKuWei} from "@/api/base/warehouseinfoKuwei";
import { listWarehouseinfoKuwei } from "@/api/base/warehouseinfoKuwei";
import Treeselect from "@riophae/vue-treeselect";
import { getWarehouseInfoByDeptId } from "@/api/base/warehouseinfo";
import { treeselect } from "@/api/system/dept";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {getLiSupplier} from "@/api/supplychain/supplier";
export default {
  name: "AssetChuku",
  components: {ChukuAdd,Treeselect},
  dicts: ['asset_chuku_type','zcrk_sh_state'],
  data() {
    return {
      openChange:false,
      //供应商字典
      supplyOptions: [],
      deptOptions:undefined,
      warehouseinfo:[],
      formSh:{},
      checkList:[],
      zcOpen:false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 资产出库表格数据
      AssetChukuList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        chukuType: null,
        assetType: null,
        assetName: null,
        barcode: null,
        spec: null,
        supplierName: null,
        manufactureName: null,
      },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "导入`AssetChuku`信息",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/sales/AssetChuku/importData"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        chukuType: [
          { required: true, message: "请选择出库类型", trigger: "blur" }
        ],
        deptId: [
          { required: true, message: "请选择科室", trigger: "change" }
        ]
        // assetName: [
        //   { required: true, message: "资产名称不能为空", trigger: "blur" }
        // ],
      }
    };
  },
  created() {
    this.getList();
    this.getTreeselect();
    getLiSupplier().then(response => {
      this.supplyOptions = response.data;
    });
  },
  methods: {
    handleSelect(e){
      this.form.deptName = e.label
      this.form.deptId = e.id
      console.log(this.form.deptName)
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    handleChange(row){
      let kwCode = row.warehouse[2]
      let obj = {
        pageNum:1,
        pageSize:10,
        kuweiJmCode:kwCode
      }
      listWarehouseinfoKuwei(obj).then(res=>{
        let data = res.rows[0]
        row.kuweiCode = data.kuweiCode
        row.kuquName = data.kuquName
        row.kuquCode = data.kuquCode
        row.stockId = data.stockId
        row.stockName= data.stockName
      })
    },
    //审核
    handleSh(){
      this.formSh.ids = this.ids
      cksh(this.formSh).then(res=>{
        this.$message.success('审核成功')
        this.getList()
      })

    },
    //取消审核
    handleQx(){
      this.formSh.ids = this.ids
      ckshqx(this.formSh).then(res=>{
        this.$message.success('取消审核成功')
        this.getList()
      })

    },
    //创建资产
    handleCj(){
      this.formSh.ids = this.ids
      cjzc(this.formSh).then(res=>{
        this.$message.success('创建资产成功')
        this.getList()
      })
    },
    //选择资产按钮
    checkZc(){
      this.zcOpen = true
    },
    submitZc(){
      let chukuInfo = this.$refs.chukuAdd.chukuInfo
      this.checkList = chukuInfo
      this.zcOpen = false
    },
    /** 查询资产出库列表 */
    getList() {
      this.loading = true;
      listAssetChuku(this.queryParams).then(response => {
        console.log(response,'aaaaaaaaaaa')
        this.AssetChukuList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 取消按钮
    cancelChange() {
      this.openChange = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        orgCode: null,
        orgName: null,
        chukuType: null,
        assetNumber: null,
        assetCode: null,
        assetType: null,
        assetClass: null,
        assetName: null,
        barcode: null,
        materialCode: null,
        brand: null,
        spec: null,
        buyTime: null,
        useLife: null,
        supplierCode: null,
        supplierName: null,
        manufactureCode: null,
        manufactureName: null,
        assetImg: null,
        assetMaintenance: null,
        assetPhold: null,
        assetProgramCode: null,
        assetProgramPackage: null,
        plannNum: null,
        chukuNum: null,
        unitPrice: null,
        amount: null,
        usefulLife: null,
        remark: null,
        createTime: null,
        createBy: null,
        free1: null,
        free2: null,
        free3: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.checkList = []
      this.open = true;
      this.title = "添加资产出库";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getAssetChuku(id).then(response => {
        // console.log('response',response)
        this.form = response.data;
        this.openChange = true;
        this.title = "修改资产出库";
      });
    },
    /** 提交按钮 */
    submitForm() {
      console.log(this.form)
      this.$refs["form"].validate(valid => {
        let chukuinfoAddList= this.checkList;
        if(chukuinfoAddList.length==0){
          this.$modal.alertWarning('请选择需要出库的物料!')
          return;
        }
        for(var i=0;i<chukuinfoAddList.length;i++){
          if(chukuinfoAddList[i].chukuNum==''||chukuinfoAddList[i].chukuNum==null||chukuinfoAddList[i].chukuNum==undefined|| chukuinfoAddList[i].chukuNum<=0){
            this.$modal.alertWarning('出库数量不能为空或为0')
            return;
          }
          if(chukuinfoAddList[i].chukuNum>chukuinfoAddList[i].kcNum){
            this.$modal.alertWarning('出库数量不能大于可用库存数量')
            return;
          }

        }
        this.form.infoList = this.checkList
        if (valid) {
          if (this.form.id != null) {
            updateAssetChuku(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.checkList = []
              this.open = false;
              this.getList();
            });
          } else {
            console.log(this.form,'mmmmmmmmmm')
            addAssetChuku(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.checkList = []
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    submitFormChange(){
      this.$refs["form"].validate(valid => {
          if (valid) {
            updateAssetChuku(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.checkList = []
              this.openChange = false;
              this.getList();
            });
          }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除数据？').then(function() {
        return delAssetChuku(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('sales/AssetChuku/export', {
        ...this.queryParams
      }, `AssetChuku_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "资产出库导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('sales/AssetChuku/importTemplate', {
      }, `资产出库模板.xlsx`)
    },
    /** 文件上传中处理 */
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件上传成功处理 */
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    /** 提交上传文件 */
    submitFileForm() {
      this.$refs.upload.submit();
    },
  }
};
</script>
